/*
 * @Author: gaoyu gy15354315043@163.com
 * @Date: 2024-10-21 14:13:49
 * @LastEditors: gaoyu gy15354315043@163.com
 * @LastEditTime: 2024-11-11 15:00:32
 * @Description: 
 * Copyright (c) 2024-present HBIS Digital Technology Co.,Ltd. All rights reserved. 
 */
import { default as request, cloud } from '@/framework/utils/request';
import { UpdateInfoParams, uploadType } from './types'

import { ResultData } from '@/framework/api/common';
/**
 * @description:  获取用户信息
 * @return {*}
 */
export function userDetail(): Promise<ResultData<UpdateInfoParams>> {
    return request({
        url: cloud.businessBasic + '/user/detail',
        method: 'get',
    });
}
/**
 * @description:  修改用户信息
 * @return {*}
 */
export function userEdit(data: string): Promise<ResultData<null>> {
    return request({
        url: cloud.businessBasic + '/user/edit',
        method: 'post',
        data,
    })
}
/**
 * @description:  上传图片
 * @return {*}
 */
export function updateAvatar(file: File, data: uploadType): Promise<ResultData<null>> {
    const formData = new FormData();
    formData.append("file", file);
    if (data) {
        for (const key in data) {
            formData.append(key, data[key]);
        }
    }
    return request({
        url: cloud.sysBasic + '/sysFileInfo/upload',
        method: 'post',
        data: formData,
        headers: {
            "Content-Type": "multipart/form-data",
        },
    });
}
